<?php

namespace Admin\Controller;

use Think\Controller;
use Common\Controller\AuthController;
use Think\Auth;

class UploadController extends AuthController {

    public function __construct() {
        parent::_initialize();
    }

    public function index() {
        $upload = new \Org\Util\Upload;
        $config['upload_path'] = __ROOT__ . '/Public/UploadFiles_s/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg|bmp';
        $config['encrypt_name'] = true;
        $upload->initialize($config);
        $succeed = $upload->do_upload('Filedata');
        if ($succeed) {
            $data = $upload->data();
            $data['img_src'] = __ROOT__ . '/Public/UploadFiles_s/' . $data['file_name'];
        } else {
            $data = $upload->display_errors();
        }
        return $this->json_return($data);
    }

}

?>